// ======================
// BTC价格数据模块
// ======================
const links2 = [
    { href: 'https://api.zsuuu.com/btcprice', name: "BTC价格", id: "btcprice" }
];

links2.forEach(async (link) => {
    try {
        const apiUrl = link.href;
        const response = await fetch(apiUrl);

        if (!response.ok) return;

        const data = await response.json();
        if (data) {
            try {
                document.getElementById(link.id).textContent = data;
            } catch (error) {
                document.getElementById(link.id).textContent = '异常';
            }
        }
    } catch (error) {
        // 静默处理错误
    }
});

// ======================
// 汇率数据模块
// ======================
const links1 = [
    { href: 'https://api.zsuuu.com/rmbtousd', name: "汇率", id: "rmbtousd" }
];

links1.forEach(async (link) => {
    try {
        const apiUrl = link.href;
        const response = await fetch(apiUrl);

        if (!response.ok) return;

        const data = await response.json();
        if (data) {
            try {
                document.getElementById(link.id).textContent = data;
            } catch (error) {
                document.getElementById(link.id).textContent = '异常';
            }
        }
    } catch (error) {
        // 静默处理错误
    }
});

// ======================
// 汇率数据模块
// ======================
const links6 = [
    { href: 'https://api.zsuuu.com/au9999', name: "金价", id: "au9999" }
];

links6.forEach(async (link) => {
    try {
        const apiUrl = link.href;
        const response = await fetch(apiUrl);

        if (!response.ok) return;

        const data = await response.json();
        if (data) {
            try {
                document.getElementById(link.id).textContent = data;
            } catch (error) {
                document.getElementById(link.id).textContent = '异常';
            }
        }
    } catch (error) {
        // 静默处理错误
    }
});

// ======================
// 上证指数数据模块
// ======================
const links3 = [
    { href: 'https://api.zsuuu.com/sh000001', name: "上证指数", id: "sh000001" }
];

links3.forEach(async (link) => {
    try {
        const apiUrl = link.href;
        const response = await fetch(apiUrl);

        if (!response.ok) return;

        const data = await response.json();
        if (data) {
            try {
                document.getElementById(link.id).textContent = data;
            } catch (error) {
                document.getElementById(link.id).textContent = '异常';
            }
        }
    } catch (error) {
        // 静默处理错误
    }
});

// ======================
// 沪深300指数数据模块
// ======================
const links5 = [
    { href: 'https://api.zsuuu.com/sh000300', name: "沪深300指数", id: "sh000300" }
];

links5.forEach(async (link) => {
    try {
        const apiUrl = link.href;
        const response = await fetch(apiUrl);

        if (!response.ok) return;

        const data = await response.json();
        if (data) {
            try {
                document.getElementById(link.id).textContent = data;
            } catch (error) {
                document.getElementById(link.id).textContent = '异常';
            }
        }
    } catch (error) {
        // 静默处理错误
    }
});